package com.hck.domain.health.model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 健康報告領域實體
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HealthReportEntity {
    
    private Long id;
    private Long userId;
    private String reportTitle;
    private String reportType; // 報告類型：體檢報告、健康評估等
    private String reportContent; // 報告內容
    private Integer healthScore; // 健康評分(0-100)
    private String riskLevel; // 風險等級：低、中、高
    private String recommendations; // 健康建議
    private Date generateTime; // 生成時間
    private Date validUntil; // 有效期至
    private Integer status; // 狀態：0-無效，1-有效
    private Date createTime;
    private Date updateTime;
    
    /**
     * 獲取健康等級描述
     */
    public String getHealthLevel() {
        if (healthScore == null) return "未知";
        
        if (healthScore >= 90) {
            return "優秀";
        } else if (healthScore >= 80) {
            return "良好";
        } else if (healthScore >= 70) {
            return "一般";
        } else if (healthScore >= 60) {
            return "較差";
        } else {
            return "危險";
        }
    }
    
    /**
     * 檢查報告是否有效
     */
    public boolean isValid() {
        return status != null && status == 1 && 
               (validUntil == null || validUntil.after(new Date()));
    }
    
    /**
     * 獲取風險等級顏色
     */
    public String getRiskLevelColor() {
        switch (riskLevel) {
            case "低": return "green";
            case "中": return "orange";
            case "高": return "red";
            default: return "gray";
        }
    }
}